diff --git a/lib/matplotlib/backends/backend_mixed.py b/lib/matplotlib/backends/backend_mixed.py
index 5fadb96a0f..710a0b647e 100644
--- a/lib/matplotlib/backends/backend_mixed.py
+++ b/lib/matplotlib/backends/backend_mixed.py
@@ -48,6 +48,7 @@ class MixedModeRenderer:
         self._vector_renderer = vector_renderer
 
         self._raster_renderer = None
+        self._rasterization_counter = 0
 
         # A reference to the figure is needed as we need to change
         # the figure dpi before and after the rasterization. Although
@@ -73,16 +74,18 @@ class MixedModeRenderer:
         Enter "raster" mode.  All subsequent drawing commands (until
         `stop_rasterizing` is called) will be drawn with the raster backend.
         """
-        # change the dpi of the figure temporarily.
-        self.figure.dpi = self.dpi
-        if self._bbox_inches_restore:  # when tight bbox is used
-            r = process_figure_for_rasterizing(self.figure,
-                                               self._bbox_inches_restore)
-            self._bbox_inches_restore = r
-
-        self._raster_renderer = self._raster_renderer_class(
-            self._width*self.dpi, self._height*self.dpi, self.dpi)
-        self._renderer = self._raster_renderer
+        self._rasterization_counter += 1
+        if self._rasterization_counter == 1:
+            # change the dpi of the figure temporarily.
+            self.figure.dpi = self.dpi
+            if self._bbox_inches_restore:  # when tight bbox is used
+                r = process_figure_for_rasterizing(self.figure,
+                                                   self._bbox_inches_restore)
+                self._bbox_inches_restore = r
+
+            self._raster_renderer = self._raster_renderer_class(
+                self._width*self.dpi, self._height*self.dpi, self.dpi)
+            self._renderer = self._raster_renderer
 
     def stop_rasterizing(self):
         """
@@ -90,30 +93,39 @@ class MixedModeRenderer:
         the last `start_rasterizing` call will be copied to the
         vector backend by calling draw_image.
         """
-
-        self._renderer = self._vector_renderer
-
-        height = self._height * self.dpi
-        img = np.asarray(self._raster_renderer.buffer_rgba())
-        slice_y, slice_x = cbook._get_nonzero_slices(img[..., 3])
-        cropped_img = img[slice_y, slice_x]
-        if cropped_img.size:
-            gc = self._renderer.new_gc()
-            # TODO: If the mixedmode resolution differs from the figure's
-            #       dpi, the image must be scaled (dpi->_figdpi). Not all
-            #       backends support this.
-            self._renderer.draw_image(
-                gc,
-                slice_x.start * self._figdpi / self.dpi,
-                (height - slice_y.stop) * self._figdpi / self.dpi,
-                cropped_img[::-1])
-        self._raster_renderer = None
-
-        # restore the figure dpi.
-        self.figure.dpi = self._figdpi
-
-        if self._bbox_inches_restore:  # when tight bbox is used
-            r = process_figure_for_rasterizing(self.figure,
-                                               self._bbox_inches_restore,
-                                               self._figdpi)
-            self._bbox_inches_restore = r
+        if self._rasterization_counter > 0:
+            self._rasterization_counter -= 1
+
+        if self._rasterization_counter == 0:
+            # Only reset the raster renderer when all rasterization processes are complete
+            # This check ensures that we do not encounter an AttributeError when attempting
+            # to access buffer_rgba() on a NoneType, which occurs when rasterization is
+            # reentered before the previous rasterization process has completed.
+            self._renderer = self._vector_renderer
+
+            height = self._height * self.dpi
+            if self._raster_renderer is not None:
+                img = np.asarray(self._raster_renderer.buffer_rgba())
+                slice_y, slice_x = cbook._get_nonzero_slices(img[..., 3])
+                cropped_img = img[slice_y, slice_x]
+                if cropped_img.size:
+                    gc = self._renderer.new_gc()
+                    self._renderer.draw_image(
+                        gc,
+                        slice_x.start * self._figdpi / self.dpi,
+                        (height - slice_y.stop) * self._figdpi / self.dpi,
+                        cropped_img[::-1])
+            # This check ensures that the raster renderer is only reset when all rasterization processes have completed.
+            # It prevents the AttributeError that occurs when buffer_rgba() is called on a NoneType object,
+            # which can happen if rasterization is reentered before the previous rasterization process has completed.
+            if self._rasterization_counter == 0:
+                self._raster_renderer = None
+
+            # restore the figure dpi.
+            self.figure.dpi = self._figdpi
+
+            if self._bbox_inches_restore:  # when tight bbox is used
+                r = process_figure_for_rasterizing(self.figure,
+                                                   self._bbox_inches_restore,
+                                                   self._figdpi)
+                self._bbox_inches_restore = r
